package practices;

import java.util.List;

public class PrintList {
    public static void printList(List<?> list) {
        for (Object element : list) {
            System.out.println(element + " ");
        }
        System.out.println();
    }


    public static double sumList(List<? extends Number> list) {
        double sum = 0;
        for (Number element : list) {
            sum += element.doubleValue();
        }
        return sum;
    }

    public static void main(String[] args) {
        List<String> strList = List.of("a", "b", "c");
        printList(strList);
        List<Integer> intList = List.of(1, 2, 3);
        System.out.println(sumList(intList));
        List<Double> doubleList = List.of(1.1, 2.2, 3.3);
        System.out.println(sumList(doubleList));
    }
}